import java.util.Objects;

public class Point
{
    private double x, y;

    public Point(double x,double y)
    {
        this(x,y,false);
    }

    public Point()
    {
        this(0,0);
    }

    public Point(Point p)
    {
        this(p.x,p.y);
    }

    public Point(double x,double y,boolean mustPositive)
    {
        this.x=x;
        this.y=y;
        if(mustPositive&&(this.x<0||this.y<0))
            throw new IllegalArgumentException("Argument must be positive but "+((this.x<0)?("x("+this.x+") is negative "):"")+((this.y<0)?("y("+this.y+") is negative "):""));
    }

    public boolean equals(Point o)
    {
        return Double.compare(o.x,x)==0&&Double.compare(o.y,y)==0;
    }
    //    public String toString()
//    {
//        return "Point{"+
//                "x="+x+
//                ", y="+y+
//                '}';
//    }


    public String toString(){return "new Point("+x+","+y+")";}

    public double getX()
    {
        return x;
    }

    public double getY()
    {
        return y;
    }

    //旋转指顺时针转angle弧度
    public Point revolve(Point p,double angle)
    {
        double x=this.x-p.x;
        double y=this.y-p.y;
        return new Point((double)Math.round((x*Math.cos(angle)+y*Math.sin(angle)+p.x)*10000)/10000,(double)Math.round((y*Math.cos(angle)-x*Math.sin(angle)+p.y)*10000)/10000);
    }

    public Point revolve(double angle)
    {
        return this.revolve(new Point(0,0),angle);
    }

    //注意，所有的缩放参数都是小数，1表示不缩放，0.9表示缩小为原来0.9倍，1.2表示放大为原来的1.2倍，以此类推
    public Point zoom(Point p,double percentage)
    {
        double x=this.x-p.x;
        double y=this.y-p.y;
        return new Point(x*percentage+p.x,y*percentage+p.y);
    }

    public Point zoom(double percentage)
    {
        return zoom(new Point(0,0),percentage);
    }
}
